import 'package:boss/models/cloud_printer.dart';
import 'package:boss/ui/widget/custom_list_title.dart';
import 'package:boss/ui/widget/image/base_image.dart';
import 'package:hi_common/hi_common.dart';
import 'package:flutter/material.dart';
import 'package:flutter_slidable/flutter_slidable.dart';

class PrinterItem extends StatelessWidget {
  final CloudPrinter data;
  final VoidCallback onTap;
  final VoidCallback onDelete;

  const PrinterItem({
    Key key,
    @required this.data,
    this.onTap,
    this.onDelete,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Slidable(
      actionPane: SlidableDrawerActionPane(),
      secondaryActions: <Widget>[
        IconSlideAction(
          caption: '删除',
          color: Colors.red,
          icon: Icons.delete,
          onTap: onDelete,
        ),
      ],
      child: Padding(
        padding: EdgeInsets.symmetric(
          horizontal: 30.w,
        ),
        child: CustomListTitle(
          title: '${data.printerName}',
          trailing: BaseImage(
            'assets/image/arrow_right_icon.png',
            width: 13.w,
            height: 30.w,
          ),
          onTap: onTap,
        ),
      ),
    );
  }
}
